package CGW.utils;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.util.Properties;

public class DB {
    private static DataSource ds;

    public static DataSource getDataSource() {
        if (ds == null) {
            Properties p = new Properties();
            try {
                p.load(DB.class.getResourceAsStream("/db.properties"));
                ds = DruidDataSourceFactory.createDataSource(p);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return ds;
    }
}
